<!-- acc service state
<fieldset class="cbi-section">
  <table class="cbi-section-table" id="acc_service_state_table">
    <tr class="cbi-section-table-title">
      <th class="cbi-section-table-cell"><%:Acc_Service_Name%></th>
      <th class="cbi-section-table-cell"><%:Acc_Service_Status%></th>
      <th class="cbi-section-table-cell"><%:Acc_Service_Operate%></th>
    </tr>
    <tr>
      <td><%:Acc_Service%></td>
      <td id="acc_service_state_cell"><%:Acc_Service_Status%></td>
      <td id="acc_service_state_button"><%:Acc_Service_Operate%></td>
    </tr>
  </table>
</fieldset> -->
  
<!-- acc catalog state -->
<fieldset class="cbi-section">
  <legend><%:Acc Catalog State%></legend>
  <table class="cbi-section-table" id="acc_catalog_state_table">
    <tr class="cbi-section-table-title">
      <th class="cbi-section-table-cell"><%:Acc_Catalog%></th>
      <th class="cbi-section-table-cell"><%:Acc_Catalog_Status%></th>
    </tr>
  </table>
</fieldset>


<script type="text/javascript">//<![CDATA[
    // start acc service
    function start_acc_service() {
      XHR.get('<%=luci.dispatcher.build_url("admin", "services", "acc", "start_acc_service")%>', null, function(x) {});
    }
      // start acc service
    function stop_acc_service() {
      XHR.get('<%=luci.dispatcher.build_url("admin", "services", "acc", "stop_acc_service")%>', null, function(x) {});
    }

    XHR.poll(5, '<%=url('admin/services/acc/status')%>', null, function(x, st) {
      var service_cell = document.getElementById("acc_service_state_cell");
      var button_cell = document.getElementById("acc_service_state_button");
      if (st && service_cell && button_cell) {
        service_cell.innerHTML = st["service"];
        if (st["service"] == "Acc Service Enabled" || st["service"] == "已启动" || st["service"] == "加速服务已启动")
          button_cell.innerHTML = '<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Stop Acc Service%>" onclick="return stop_acc_service()"/>';
        else
          button_cell.innerHTML = '<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Start Acc Service%>" onclick="return start_acc_service()"/>';
      }
      var catalog_table = document.getElementById("acc_catalog_state_table");
      if (st && catalog_table) {
        while(catalog_table.rows.length > 1)
          catalog_table.deleteRow(1);
        var status_map = st["state"];
        for (var typ in status_map) {
          var tr = catalog_table.insertRow(-1);
          tr.insertCell(-1).innerHTML = typ;
          tr.insertCell(-1).innerHTML = status_map[typ];
        }
      }
    });
//]]></script>
